<?php

    class ContractSoftwareMaintController extends Controller
    {

        public function filters()
        {
            return array(
                'accessControl', // perform access control for CRUD operations
                array(
                    'application.filters.RequireLoginFilter',
                ),
            );
        }
        
        public function actionSaveEquipment($contractid){
            
        }
                
        public function actionInventoryList($contractid,$page=1,$sort=NULL){
            if($page>0)$page--;
            $order =null;
            if($sort){
                $orderParams = CJSON::decode($sort);
                $order = $orderParams[0]['property'].' '.$orderParams[0]['direction'];
            }
            $dataProvider = new CActiveDataProvider('SoftwareMaintInventory',array(
                'criteria'=>array(
                    'condition'=>'contractid=:contractid',
                    'params'=>array(
                        'contractid'=>$contractid
                    ),
                    'order'=>$order
                ),
                'pagination'=>array(
                    'pageSize'=>25,
                    'currentPage'=>$page
                )
            ));
            $rs =array();
            $rs['totalCount'] = $dataProvider->getTotalItemCount();
            $rs['data'] = array();
            foreach($dataProvider->getData() as $index=>$item){
                $rs['data'][] = $item->attributes;
            }
            echo json_encode($rs);
        }

    }

?>
